class UserAccount {

  String firstName
  String lastName
  String email
  String password

  static mapping = {
    cache true
  }

  static constraints = {
    firstName(nullable: false, blank: false)
    lastName(nullable: false, blank: false)
    email(email: true, unique: true, nullable: false, blank: false)
    password(blank: false, nullable: false)
  }

  String toString() {
    "${lastName}, ${firstName} [${id}]"
  }




  boolean equals(o) {
    if (this.is(o)) return true;

    if (!o || getClass() != o.class) return false;

    UserAccount that = (UserAccount) o;

    if (email ? !email.equals(that.email) : that.email != null) return false;
    if (firstName ? !firstName.equals(that.firstName) : that.firstName != null) return false;
    if (lastName ? !lastName.equals(that.lastName) : that.lastName != null) return false;
    if (password ? !password.equals(that.password) : that.password != null) return false;

    return true;
  }

  int hashCode() {
    int result;

    result = (firstName ? firstName.hashCode() : 0);
    result = 31 * result + (lastName ? lastName.hashCode() : 0);
    result = 31 * result + (email ? email.hashCode() : 0);
    result = 31 * result + (password ? password.hashCode() : 0);
    return result;
  }
}
